package com.nit.vehicle.Actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.nit.vehicle.dao.LoginFormDAO;
import com.nit.vehicle.dto.LoginFormDTO;
import com.nit.vehicle.fb.LoginFormFB;

public class LoginFormAction extends Action  {
	public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) throws Exception {
		LoginFormFB lffb = (LoginFormFB) form;
		
		LoginFormDTO lfdto = new LoginFormDTO();
		lfdto.setUserName(lffb.getUserName());
		lfdto.setPwd(lffb.getPwd());
		
		LoginFormDAO lfdao = new LoginFormDAO();
		if(lfdao.authenticate(lfdto)){
			return mapping.findForward("success");
		}
		return mapping.findForward("fail");
	}
}
